package cn.pink.core;

import com.google.protobuf.GeneratedMessageV3;

import java.util.HashMap;
import java.util.Map;

/**
 * 封装客户端消息的基类
 * @Author: pink
 * @Date: 2022/6/30 11:22
 */
public class MsgParamBase {
    /** 客户端消息 */
    private GeneratedMessageV3 msg;
    /** 上下文参数 */
    private Map<String, Object> param = new HashMap<>();

    public MsgParamBase(GeneratedMessageV3 msg) {
        super();
        this.msg = msg;
    }

    @SuppressWarnings("unchecked")
    public <T> T getMsg() {
        return (T) msg;
    }

    public void setMsg(GeneratedMessageV3 msg) {
        this.msg = msg;
    }

    @SuppressWarnings("unchecked")
    public <T> T get(String key) {
        return (T) param.get(key);
    }

    public void put(String key, Object value) {
        param.put(key, value);
    }
}
